package com.sojson.config.mybatis;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;

/**
 * Mybatis配置类
 * 
 * @author liu
 * @date 2022-01-27
 */
@Configuration
/** 扫描接口文件要配合application.properties的mybatis.mapper-locations */
@MapperScan({"${so.mybatis.mapper.interface.locations}"})
public class MybatisConfig {

    /** Mybatis-Plus全局配置 */
    @Bean(name = "globalConfig")
    @ConfigurationProperties(prefix = "mybatis-plus.global-config")
    public GlobalConfig globalConfig() {
        return new GlobalConfig();
    }

    /**
     * 防止全表更新与删除
     * 
     * @return
     */
    @Bean
    public BlockAttackInnerInterceptor blockAttackInnerInterceptor() {
        return new BlockAttackInnerInterceptor();
    }

}